define(["jquery", "easy-admin"], function ($, ea) {
    $.ajaxSettings.async = false;
    var admin_type = ''
    $.ajax({
        url:'/admin/index/loginuser',
        success:(res)=>{
            console.log(res.data,'res.data')
            admin_type = res.data
        }
    })
    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'good.goodlist/index',
        add_url: 'good.goodlist/add',
        edit_url: 'good.goodlist/edit',
        delete_url: 'good.goodlist/delete',
        export_url: 'good.goodlist/export',
        modify_url: 'good.goodlist/modify',
    };
    var col = [[
        {field: 'id', minWidth: 80, title: 'ID',search: false},
        {field: 'title', minWidth: 80, title: '商品名称'},
        {field: 'good_type_name', minWidth: 80, title: '商品分类',search: false},
        {field: 'bottom_price', minWidth: 80, title: '最低价（元）',search: false},
        {field: 'stock', minWidth: 80, title: '库存',search: false},
        {field: 'sales_volume', minWidth: 80, title: '销量',search: false},
        // {field: 'status', title: '是否禁用', templet: ea.table.switch, search: false},
        {field: 'create_time', title: '添加时间',search: false},
        {width: 250, title: '操作', templet: ea.table.tool}
    ]]
    if(admin_type==1){
        col = [[
            {field: 'id', minWidth: 80, title: 'ID',search: false},
            {field: 'title', minWidth: 80, title: '商品名称'},
            {field: 'good_type_name', minWidth: 80, title: '商品分类',search: false},
            // {field: 'bottom_price', minWidth: 80, title: '最低价（元）',search: false},
            {field: 'stock', minWidth: 80, title: '库存',search: false},
            // {field: 'sales_volume', minWidth: 80, title: '销量',search: false},
            // {field: 'status', title: '是否禁用', templet: ea.table.switch, search: false},
            // {field: 'create_time', title: '添加时间',search: false},
            // {width: 250, title: '操作', templet: ea.table.tool}
        ]]
    }

    var Controller = {
        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh','add'],
                cols: col
            });
            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };


    return Controller;
});